import { IPSAppDELogicNodeParam } from '../../app/dataentity/ipsapp-delogic-node-param';
import { IPSDELogic } from './ipsdelogic';
import { IPSDELogicNodeParam } from './ipsdelogic-node-param';
import { IPSDELogicParam } from './ipsdelogic-param';
import { IPSSysSequence } from '../../res/ipssys-sequence';
import { IPSSysTranslator } from '../../res/ipssys-translator';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDELogicNodeParamImpl extends PSModelObjectImpl implements IPSDELogicNodeParam, IPSAppDELogicNodeParam {
  get aggMode(): 'SUM' | 'AVG' | 'MAX' | 'MIN' | 'COUNT' | 'GROUP' | 'USER' | 'USER2' | 'USER3' | 'USER4' {
    return this.M.aggMode;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get dstFieldName(): string {
    return this.M.dstFieldName;
  }

  get dstIndex(): number {
    return this.M.dstIndex != null ? this.M.dstIndex : -1;
  }

  protected dstpsdelogicparam: IPSDELogicParam | null = null;

  getDstPSDELogicParam(): IPSDELogicParam | null {
    if (this.dstpsdelogicparam != null) return this.dstpsdelogicparam;
    const value = this.M.getDstPSDELogicParam;
    if (value == null) {
      return null;
    }
    const ipsdelogic = this.getParentPSModelObject('dataentity.logic.IPSDELogic') as IPSDELogic;
    if (ipsdelogic != null) {
      this.dstpsdelogicparam = ipsdelogic.findPSDELogicParam(value);
    }
    return this.dstpsdelogicparam;
  }

  get dstPSDELogicParam(): IPSDELogicParam | null {
    return this.getDstPSDELogicParam();
  }

  getDstPSDELogicParamMust(): IPSDELogicParam {
    const value = this.getDstPSDELogicParam();
    if (value == null) {
      throw new Error('未指定目标逻辑参数');
    }
    return value;
  }

  get dstSortDir(): 'ASC' | 'DESC' {
    return this.M.dstSortDir;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get expression(): string {
    return this.M.expression;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected pssyssequence: IPSSysSequence | null = null;

  getPSSysSequence(): IPSSysSequence | null {
    if (this.pssyssequence != null) return this.pssyssequence;
    const value = this.M.getPSSysSequence;
    if (value == null) {
      return null;
    }
    this.pssyssequence = this.getPSModel4('res.IPSSysSequence', value, 'getPSSysSequence') as IPSSysSequence;
    return this.pssyssequence;
  }

  get psSysSequence(): IPSSysSequence | null {
    return this.getPSSysSequence();
  }

  getPSSysSequenceMust(): IPSSysSequence {
    const value = this.getPSSysSequence();
    if (value == null) {
      throw new Error('未指定系统值序列对象');
    }
    return value;
  }

  protected pssystranslator: IPSSysTranslator | null = null;

  getPSSysTranslator(): IPSSysTranslator | null {
    if (this.pssystranslator != null) return this.pssystranslator;
    const value = this.M.getPSSysTranslator;
    if (value == null) {
      return null;
    }
    this.pssystranslator = this.getPSModel4('res.IPSSysTranslator', value, 'getPSSysTranslator') as IPSSysTranslator;
    return this.pssystranslator;
  }

  get psSysTranslator(): IPSSysTranslator | null {
    return this.getPSSysTranslator();
  }

  getPSSysTranslatorMust(): IPSSysTranslator {
    const value = this.getPSSysTranslator();
    if (value == null) {
      throw new Error('未指定系统值转换器对象');
    }
    return value;
  }

  get paramAction():
    | 'SETPARAMVALUE'
    | 'RESETPARAM'
    | 'COPYPARAM'
    | 'SQLPARAM'
    | 'SFPLUGINPARAM'
    | 'BINDPARAM'
    | 'APPENDPARAM'
    | 'SORTPARAM'
    | 'RENEWPARAM'
    | 'WEBURIPARAM'
    | 'WEBHEADERPARAM'
    | 'MERGEMAPPARAM'
    | 'AGGREGATEMAPPARAM' {
    return this.M.paramAction;
  }

  get srcFieldName(): string {
    return this.M.srcFieldName;
  }

  get srcIndex(): number {
    return this.M.srcIndex != null ? this.M.srcIndex : -1;
  }

  protected srcpsdelogicparam: IPSDELogicParam | null = null;

  getSrcPSDELogicParam(): IPSDELogicParam | null {
    if (this.srcpsdelogicparam != null) return this.srcpsdelogicparam;
    const value = this.M.getSrcPSDELogicParam;
    if (value == null) {
      return null;
    }
    const ipsdelogic = this.getParentPSModelObject('dataentity.logic.IPSDELogic') as IPSDELogic;
    if (ipsdelogic != null) {
      this.srcpsdelogicparam = ipsdelogic.findPSDELogicParam(value);
    }
    return this.srcpsdelogicparam;
  }

  get srcPSDELogicParam(): IPSDELogicParam | null {
    return this.getSrcPSDELogicParam();
  }

  getSrcPSDELogicParamMust(): IPSDELogicParam {
    const value = this.getSrcPSDELogicParam();
    if (value == null) {
      throw new Error('未指定源逻辑参数');
    }
    return value;
  }

  get srcSize(): number {
    return this.M.srcSize != null ? this.M.srcSize : -1;
  }

  get srcValue(): string {
    return this.M.srcValue;
  }

  get srcValueStdDataType(): 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 {
    return this.M.srcValueStdDataType != null ? this.M.srcValueStdDataType : 0;
  }

  get srcValueType():
    | 'SRCDLPARAM'
    | 'WEBCONTEXT'
    | 'APPDATA'
    | 'APPLICATION'
    | 'SESSION'
    | 'DATACONTEXT'
    | 'ENVPARAM'
    | 'VIEWPARAM'
    | 'NONEVALUE'
    | 'NULLVALUE'
    | 'SRCVALUE'
    | 'EXPRESSION'
    | 'COUNT'
    | 'AGGREGATION'
    | 'SEQUENCE' {
    return this.M.srcValueType;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get outTranslate(): boolean {
    return this.M.outTranslate != null ? this.M.outTranslate : false;
  }

  get cls(): string {
    return 'PSDELogicNodeParamImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'app.dataentity.IPSAppDELogicNodeParam' || cls == 'dataentity.logic.IPSDELogicNodeParam') return true;
    return super.instanceof(cls);
  }
}
